<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: {2021/5/23}
 * Time: {20:23}
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

namespace app\admin\middleware;


use think\facade\Session;
use think\Response;

class Auth
{
    public function handle($request, \Closure $next)
    {
        $pathinfo = $request->pathinfo();
        //dump($pathinfo);exit();
        if (!preg_match('/login/', strtolower($pathinfo))) {
            //dump($pathinfo);exit();
            $getSession = Session::get(config('admin.session_admin'));

            if (empty($getSession)) {
                return redirect((string)url('login/index'));
            }
        }
        return $next($request);
    }

    /**
     * 结束调度
     * @param Response $response
     */
    public function end(Response $response)
    {

    }
}